home *** CD-ROM | disk | FTP | other *** search
/ Power CD / Power CD ATARI-Rechner Lieben.iso / ALLERLEI / GOBJ_112 / UNITS / OPROCS.PAS < prev    next >
Encoding:
Pascal/Delphi Source File  |  1994-04-11  |  16.9 KB  |  810 lines

  1. {**************************************
  2.  *  O b j e c t G E M   Version 1.12  *
  3.  *  Copyright 1992-94 by Thomas Much  *
  4.  **************************************
  5.  *         Unit  O P R O C S          *
  6.  **************************************
  7.  *    Softdesign Computer Software    *
  8.  *    Thomas Much, Gerwigstraße 46,   *
  9.  *  76131 Karlsruhe, (0721) 62 28 41  *
  10.  *         Thomas Much @ KA2          *
  11.  *  UK48@ibm3090.rz.uni-karlsruhe.de  *
  12.  **************************************
  13.  *    erstellt am:        13.07.1992  *
  14.  *    letztes Update am:  11.04.1994  *
  15.  **************************************}
  16.  
  17. {
  18.   WICHTIGE ANMERKUNGEN ZUM QUELLTEXT:
  19.  
  20.   ObjectGEM wird ab sofort mit dem _vollständigen_ Quelltext ausgeliefert,
  21.   d.h. jeder kann sich die Unit selbst compilieren, womit die extrem
  22.   lästigen Kompatibilitätsprobleme mit den PP-Releases beseitigt sind.
  23.   ObjectGEM ist und bleibt aber trotzdem SHAREWARE, d.h. wer die Biblio-
  24.   thek regelmäßig benutzt, muß sich REGISTRIEREN lassen (so wie bisher).
  25.   Im Moment gibt es dafür dann "nur" die neueste Version; eine geTEXte
  26.   Doku ist aber in Arbeit, so daß auch ein gedrucktes Handbuch immer
  27.   wahrscheinlicher wird.
  28.  
  29.   Der Quelltext enthält z.Z. noch _keine_ Kommentare; wer sich dennoch die
  30.   Mühe macht, ihn zu lesen, wird feststellen, daß er außerdem noch recht
  31.   "wirr" und teilweise umständlich geschrieben ist, oder daß er evtl. auch
  32.   unnötige Teile enthält. Das liegt daran, daß dieser Quelltext eigentlich
  33.   gar nicht für eine Veröffentlichung gedacht war, aber immer häufiger auf-
  34.   tretende PP-Updates haben mich schier zur Verzweiflung getrieben...
  35.   Das alles sollte aber kein Grund sein, ObjectGEM nicht einzusetzen, denn
  36.   sobald nach "außen" die von mir gewünschte Funktionalität erreicht ist
  37.   (d.h. wenn alle wichtigen Objekte vorhanden sind, z.B. TEditWindow etc.),
  38.   werde ich mich um die "innere" Optimierung kümmern (dazu gehören dann
  39.   auch die Kommentare). Die bisher geschriebenen ObjectGEM-Anwendungen
  40.   können dann natürlich weiterverwendet werden.
  41.  
  42.   Wer beim Durchstöbern des Textes auf vermeintliche Fehler oder verbesse-
  43.   rungswürdige Stellen trifft (von letzterem gibt es sicherlich noch viele),
  44.   kann mir dies gerne mitteilen - ich habe auch ich nichts gegen kostenlos
  45.   zur Verfügung gestellte optimierte Routinen (sofern sich jemand die Mühe
  46.   macht). Wer in anderen Projekten, die nicht in direkter Konkurrenz zu
  47.   ObjectGEM stehen, einzelne Routinen verwenden möchte, wendet sich bitte
  48.   an mich (ein solcher Austausch sollte kein Problem sein).
  49.  
  50.   Wer sich auf nicht dokumentierte "implementation"- oder "private"-Eigen-
  51.   schaften verläßt, darf sich nicht über Inkompatibilitäten zu späteren
  52.   Versionen wundern; wer meint, eine Dokumentationslücke entdeckt zu haben
  53.   (außer dem "Abgrund" des noch fehlenden Handbuchs...), kann mir dies
  54.   gerne mitteilen.
  55.  
  56.   WICHTIG: Wer den Quelltext verändert und dann Probleme beim Compilieren,
  57.   Ausführen o.ä. hat, kann nicht damit rechnen, daß ich den Fehler suche;
  58.   tritt der Fehler allerdings auch mit dem Original-Quelltext auf, würde
  59.   ich mich über eine genaue Fehlerbeschreibung freuen. Veränderte Quell-
  60.   texte dürfen _nicht_ weitergegeben werden, dies wäre ein Verstoß gegen
  61.   das Copyright!
  62.  
  63.   Kleine Info zum Schluß: Als "default tabsize" verwende ich 2. Wer drei
  64.   Punkte ("...") im Quelltext entdeckt, hat eine Stelle gefunden, an der
  65.   ich z.Z. arbeite ;-)
  66.  
  67.   "Möge die OOP mit Euch sein!"
  68. }
  69.  
  70.  
  71. {$IFDEF DEBUG}
  72.     {$B+,D+,G-,I-,L+,N-,P-,Q+,R+,S+,T-,V-,X+,Z+}
  73. {$ELSE}
  74.     {$B+,D-,G-,I-,L-,N-,P-,Q-,R-,S-,T-,V-,X+,Z+}
  75. {$ENDIF}
  76.  
  77. unit OProcs;
  78.  
  79. interface
  80.  
  81. uses
  82.  
  83.     OTypes;
  84.  
  85.  
  86. function NewStr(s: string): PString;
  87. procedure DisposeStr(var p: PString);
  88. function ChrNew(s: string): PChar;
  89. procedure ChrDispose(var p: PChar);
  90. function StrLPas(p: PChar; maxc: integer): string;
  91. function StrPLeft(s: string; c: integer): string;
  92. function StrPRight(s: string; c: integer): string;
  93. function StrPTrimF(s: string): string;
  94. procedure StrPTrim(var s: string);
  95. function StrPSpace(anz: integer): string;
  96. function StrPUpper(s: string): string;
  97. function RPos(subStr,Str: string): byte;
  98. function UpChar(ch: char): char;
  99.  
  100. function ltoa(l: longint): string;
  101. function atol(s: string): longint;
  102. function ftoa(f: real): string;
  103. function atof(s: string): real;
  104.  
  105. function NewCookie(cookie: TCookieID; value: longint): boolean;
  106. function RemoveCookie(cookie: TCookieID): boolean;
  107. function GetCookie(cookie: TCookieID; var value: longint): boolean;
  108. function ChangeCookie(cookie: TCookieID; newval: longint): boolean;
  109.  
  110. procedure Abstract;
  111. procedure GetDesk(var r: GRECT);
  112. function GetOSHeaderPtr: pointer;
  113. function MapKey(key: integer): integer;
  114. function BootDevice: char;
  115. function Exist(FileName: string): boolean;
  116. function GetTempFilename: string;
  117. function GetPath(FileName: string): string;
  118. function GetDrives: longint;
  119.  
  120. function MiNTVersion: word;
  121. function GEMDOSVersion: word;
  122. function TOSVersion: word;
  123. function TOSDate: longint;
  124. function VtoS(w: word): string;
  125. function DtoS(l: longint): string;
  126.  
  127. function Max(a,b: longint): longint;
  128. function Min(a,b: longint): longint;
  129. function Between(x,min,max: longint): boolean;
  130. function Sgn(x: longint): integer;
  131. function Ptr(hi,lo: word): pointer;
  132. function HiWord(p: pointer): word;
  133. function LoWord(p: pointer): word;
  134. function bTst(value,mask: longint): boolean;
  135.  
  136. procedure GRtoA2(var r: GRECT);
  137. procedure A2toGR(var r: GRECT);
  138. function rc_intersect(r1: GRECT; var r2: GRECT): boolean;
  139. procedure form_box(flag: integer; r: GRECT);
  140.  
  141.  
  142.  
  143. implementation
  144.  
  145. uses
  146.  
  147.     Strings,Tos,Gem;
  148.  
  149. const
  150.  
  151.     _bootdev   = $446;
  152.     _sysbase   = $4f2;
  153.     _p_cookies = $5a0;
  154.  
  155. var
  156.  
  157.     kt: KEYTABPtr;
  158.  
  159.  
  160. procedure Abstract;
  161.  
  162.     begin
  163.         write('Call to abstract method ');
  164.         runerror(211)
  165.     end;
  166.  
  167.  
  168. function NewStr(s: string): PString;
  169.   var l: integer;
  170.       p: PString;
  171.  
  172.   begin
  173.     l:=length(s);
  174.     if (l=0) then NewStr:=nil
  175.     else
  176.       begin
  177.         getmem(p,l+1);
  178.         if p<>nil then p^:=s;
  179.         NewStr:=p
  180.       end
  181.   end;
  182.  
  183.  
  184. procedure DisposeStr(var p: PString);
  185.  
  186.   begin
  187.     if p<>nil then
  188.             begin
  189.                 freemem(p,length(p^)+1);
  190.                 p:=nil
  191.             end
  192.     end;
  193.  
  194.  
  195. function ChrNew(s: string): PChar;
  196.     var l: integer;
  197.         p: PChar;
  198.  
  199.     begin
  200.         l:=length(s);
  201.         if l>0 then
  202.             if pos(#0,s)>0 then l:=pos(#0,s)-1;
  203.         getmem(p,l+1);
  204.         if p<>nil then StrPCopy(p,s);
  205.         ChrNew:=p
  206.     end;
  207.  
  208.  
  209. procedure ChrDispose(var p: PChar);
  210.  
  211.     begin
  212.         if p<>nil then
  213.             begin
  214.                 freemem(p,StrLen(p)+1);
  215.                 p:=nil
  216.             end
  217.     end;
  218.  
  219.  
  220. function StrPLeft(s: string; c: integer): string;
  221.  
  222.     begin
  223.         if c<0 then c:=0;
  224.         if c>255 then c:=255;
  225.         StrPLeft:=copy(s,1,c)
  226.     end;
  227.  
  228.  
  229. function StrPRight(s: string; c: integer): string;
  230.     var l: integer;
  231.  
  232.     begin
  233.         l:=length(s);
  234.         if c<0 then c:=0;
  235.         if c>=l then StrPRight:=s
  236.             else StrPRight:=copy(s,l+1-c,c)
  237.     end;
  238.  
  239.  
  240. function StrPTrimF(s: string): string;
  241.     label _lagain,_ragain;
  242.  
  243.     var s1: string[1];
  244.  
  245.     begin
  246.         _lagain:
  247.         s1:=StrPLeft(s,1);
  248.         if (s1=#0) or (s1=' ') then
  249.             begin
  250.                 s:=StrPRight(s,length(s)-1);
  251.                 goto _lagain
  252.             end;
  253.         _ragain:
  254.         s1:=StrPRight(s,1);
  255.         if (s1=#0) or (s1=' ') then
  256.             begin
  257.                 s:=StrPLeft(s,length(s)-1);
  258.                 goto _ragain
  259.             end;
  260.         StrPTrimF:=s
  261.     end;
  262.  
  263.  
  264. procedure StrPTrim(var s: string);
  265.  
  266.     begin
  267.         s:=StrPTrimF(s)
  268.     end;
  269.  
  270.  
  271. function StrPSpace(anz: integer): string;
  272.     var s: string;
  273.         q: integer;
  274.  
  275.     begin
  276.         s:='';
  277.         if anz>0 then
  278.             begin
  279.                 if anz>255 then anz:=255;
  280.                 for q:=1 to anz do s:=s+' '
  281.             end;
  282.         StrPSpace:=s
  283.     end;
  284.  
  285.  
  286. function StrPUpper(s: string): string;
  287.     var q: integer;
  288.  
  289.     begin
  290.         if length(s)>0 then
  291.             for q:=1 to length(s) do s[q]:=UpChar(s[q]);
  292.         StrPUpper:=s
  293.     end;
  294.  
  295.  
  296. function RPos(subStr,Str: string): byte;
  297.     label _again;
  298.  
  299.     var wo,ret: integer;
  300.  
  301.     begin
  302.         ret:=0;
  303.         _again:
  304.         wo:=pos(subStr,Str);
  305.         if wo>0 then
  306.             begin
  307.                 Str:=StrPRight(Str,length(Str)-wo);
  308.                 inc(ret,wo);
  309.                 goto _again
  310.             end;
  311.         RPos:=ret
  312.     end;
  313.  
  314.  
  315. function UpChar(ch: char): char;
  316.  
  317.     begin
  318.         case ch of
  319.             'ä': UpChar:='Ä';
  320.             'ö': UpChar:='Ö';
  321.             'ü': UpChar:='Ü'
  322.         else
  323.             UpChar:=upcase(ch)
  324.         end
  325.     end;
  326.  
  327.  
  328. function ltoa(l: longint): string;
  329.     var s: string;
  330.  
  331.     begin
  332.         str(l,s);
  333.         ltoa:=s
  334.     end;
  335.  
  336.  
  337. function atol(s: string): longint;
  338.     var l    : longint;
  339.         dummy: integer;
  340.  
  341.     begin
  342.         StrPTrim(s);
  343.         if StrPLeft(s,1)='+' then s:=StrPTrimF(StrPRight(s,length(s)-1));
  344.         val(s,l,dummy);
  345.         atol:=l
  346.     end;
  347.  
  348.  
  349. function ftoa(f: real): string;
  350.     var s: string;
  351.  
  352.     begin
  353.         str(f:0:10,s);
  354.         while StrPRight(s,1)='0' do s:=StrPLeft(s,length(s)-1);
  355.         if StrPRight(s,1)='.' then s:=s+'0';
  356.         ftoa:=s
  357.     end;
  358.  
  359.  
  360. function atof(s: string): real;
  361.     var f    : real;
  362.         dummy: integer;
  363.  
  364.     begin
  365.         StrPTrim(s);
  366.         if StrPLeft(s,1)='+' then s:=StrPTrimF(StrPRight(s,length(s)-1));
  367.         val(s,f,dummy);
  368.         atof:=f
  369.     end;
  370.  
  371.  
  372. function Sgn(x: longint): integer;
  373.  
  374.     begin
  375.         if x>0 then Sgn:=1
  376.         else
  377.             if x<0 then Sgn:=-1
  378.             else
  379.                 Sgn:=0
  380.     end;
  381.  
  382.  
  383. function Ptr(hi,lo: word): pointer;
  384.  
  385.     begin
  386.         Ptr:=pointer(hi*65536+lo)
  387.     end;
  388.  
  389.  
  390. function GetCookieJar: PCookie;
  391.     var oldstack: longint;
  392.  
  393.     begin
  394.         if Super(pointer(1))=0 then oldstack:=Super(nil)
  395.     else
  396.         oldstack:=0;
  397.     GetCookieJar:=PCookie(pointer(_p_cookies)^);
  398.     if oldstack<>0 then Super(pointer(oldstack))
  399.     end;
  400.  
  401.  
  402. function NewCookie(cookie: TCookieID; value: longint): boolean;
  403.     var cookiejar: PCookie;
  404.         anz,maxc : longint;
  405.  
  406.     begin
  407.         NewCookie:=false;
  408.         cookiejar:=GetCookieJar;
  409.         if cookiejar<>nil then
  410.             begin
  411.                 anz:=1;
  412.                 while PLongint(cookiejar)^<>0 do
  413.                     begin
  414.                         inc(longint(cookiejar),8);
  415.                         inc(anz)
  416.                     end;
  417.                 maxc:=cookiejar^.Val;
  418.                 if anz<maxc then
  419.                     begin
  420.                         with cookiejar^ do
  421.                             begin
  422.                                 ID:=cookie;
  423.                                 Val:=value
  424.                             end;
  425.                         inc(longint(cookiejar),8);
  426.                         with cookiejar^ do
  427.                             begin
  428.                                 ID:=#0#0#0#0;
  429.                                 Val:=maxc
  430.                             end;
  431.                         NewCookie:=true
  432.                     end
  433.             end
  434.     end;
  435.  
  436.  
  437. function RemoveCookie(cookie: TCookieID): boolean;
  438.     var cookiejar,cjo: PCookie;
  439.  
  440.     begin
  441.         RemoveCookie:=false;
  442.         cookiejar:=GetCookieJar;
  443.         if cookiejar<>nil then
  444.             begin
  445.                 while (PLongint(cookiejar)^<>0) and (cookiejar^.ID<>cookie) do
  446.                     inc(longint(cookiejar),8);
  447.                 if PLongint(cookiejar)^<>0 then
  448.                     begin
  449.                         cjo:=cookiejar;
  450.                         inc(longint(cookiejar),8);
  451.                         repeat
  452.                             cjo^.ID:=cookiejar^.ID;
  453.                             cjo^.Val:=cookiejar^.Val;
  454.                             cjo:=cookiejar;
  455.                             inc(longint(cookiejar),8)
  456.                         until PLongint(cjo)^=0;
  457.                         RemoveCookie:=true
  458.                     end
  459.             end
  460.     end;
  461.  
  462.  
  463. function GetCookie(cookie: TCookieID; var value: longint): boolean;
  464.   var cookiejar: PCookie;
  465.  
  466.   begin
  467.       GetCookie:=false;
  468.     cookiejar:=GetCookieJar;
  469.     if cookiejar<>nil then
  470.             while PLongint(cookiejar)^<>0 do
  471.                 with cookiejar^ do
  472.                     if ID=cookie then
  473.                         begin
  474.                             value:=Val;
  475.                             GetCookie:=true;
  476.                             exit
  477.                         end
  478.                     else
  479.                         inc(longint(cookiejar),8)
  480.   end;
  481.  
  482.  
  483. function ChangeCookie(cookie: TCookieID; newval: longint): boolean;
  484.   var cookiejar: PCookie;
  485.  
  486.   begin
  487.       ChangeCookie:=false;
  488.     cookiejar:=GetCookieJar;
  489.     if cookiejar<>nil then
  490.             while PLongint(cookiejar)^<>0 do
  491.                 with cookiejar^ do
  492.                     if ID=cookie then
  493.                         begin
  494.                             Val:=newval;
  495.                             ChangeCookie:=true;
  496.                             exit
  497.                         end
  498.                     else
  499.                         inc(longint(cookiejar),8)
  500.   end;
  501.  
  502.  
  503. function GetOSHeaderPtr: pointer;
  504.     var oldstack: longint;
  505.         p       : pointer;
  506.  
  507.     begin
  508.         if Super(pointer(1))=0 then oldstack:=super(nil)
  509.         else
  510.             oldstack:=0;
  511.         p:=pointer(PLongint(_sysbase)^);
  512.         if oldstack<>0 then super(pointer(oldstack));
  513.         GetOSHeaderPtr:=pointer(PLongint(longint(p)+8)^)
  514.     end;
  515.  
  516.  
  517. function MapKey(key: integer): integer;
  518.     var keystate,scancode,ret: integer;
  519.  
  520.     begin
  521.         if kt=nil then kt:=Keytbl(pointer(-1),pointer(-1),pointer(-1));
  522.         scancode:=key shr 8;
  523.         keystate:=Kbshift(-1);
  524.         if bTst(keystate,KsALT) and Between(scancode,$78,$83) then dec(scancode,$76);
  525.         if bTst(keystate,KsCAPS) then ret:=PByte(longint(kt^.capslock)+scancode)^
  526.         else
  527.             begin
  528.                 if (keystate and KsSHIFT)>0 then
  529.                     begin
  530.                         if Between(scancode,KbF11,KbF20) then ret:=PByte(longint(kt^.shift)+scancode-$19)^
  531.                         else
  532.                             ret:=PByte(longint(kt^.shift)+scancode)^
  533.                     end
  534.                 else
  535.                     ret:=PByte(longint(kt^.unshift)+scancode)^
  536.             end;
  537.         if ret=0 then ret:=integer(scancode or KbSCAN)
  538.         else
  539.             if ((scancode=$4a) or (scancode=$4e) or Between(scancode,$63,$72)) then ret:=ret or KbNUM;
  540.         MapKey:=integer(ret or (keystate shl 8))
  541.     end;
  542.  
  543.  
  544. function BootDevice: char;
  545.     var oldstack: longint;
  546.  
  547.     begin
  548.         if Super(pointer(1))=0 then oldstack:=super(nil)
  549.         else
  550.             oldstack:=0;
  551.         BootDevice:=chr(PWord(_bootdev)^+65);
  552.         if oldstack<>0 then super(pointer(oldstack))
  553.     end;
  554.  
  555.  
  556. function MiNTVersion: word;
  557.     var mver: longint;
  558.  
  559.     begin
  560.         if GetCookie('MiNT',mver) then MiNTVersion:=mver
  561.         else
  562.             MiNTVersion:=0
  563.     end;
  564.  
  565.  
  566. function GEMDOSVersion: word;
  567.  
  568.     begin
  569.         GEMDOSVersion:=hi(Sversion)+(lo(Sversion) shl 8)
  570.     end;
  571.  
  572.  
  573. function TOSVersion: word;
  574.  
  575.     begin
  576.         TOSVersion:=PWord(longint(GetOSHeaderPtr)+2)^
  577.     end;
  578.  
  579.  
  580. function TOSDate: longint;
  581.  
  582.     begin
  583.         TOSDate:=PLongint(longint(GetOSHeaderPtr)+24)^
  584.     end;
  585.  
  586.  
  587. function Max(a,b: longint): longint;
  588.  
  589.     begin
  590.         if a>b then Max:=a else Max:=b
  591.     end;
  592.     
  593.     
  594. function Min(a,b: longint): longint;
  595.  
  596.     begin
  597.         if a<b then Min:=a else Min:=b
  598.     end;
  599.  
  600.  
  601. function Between(x,min,max: longint): boolean;
  602.  
  603.     begin
  604.         Between:=((x>=min) and (x<=max))
  605.     end;
  606.  
  607.  
  608. function HiWord(p: pointer): word;
  609.  
  610.     begin
  611.         HiWord:=word(longint(p) div 65536)
  612.     end;
  613.  
  614.  
  615. function LoWord(p: pointer): word;
  616.  
  617.     begin
  618.         LoWord:=word(longint(p) mod 65536)
  619.     end;
  620.  
  621.  
  622. function bTst(value,mask: longint): boolean;
  623.  
  624.     begin
  625.         bTst:=((value and mask)=mask)
  626.     end;
  627.  
  628.  
  629. procedure GRtoA2(var r: GRECT);
  630.  
  631.     begin
  632.         with r do
  633.             begin
  634.                 X1:=X;
  635.                 Y1:=Y;
  636.                 X2:=X+W-1;
  637.                 Y2:=Y+H-1
  638.             end
  639.     end;
  640.  
  641.  
  642. procedure A2toGR(var r: GRECT);
  643.  
  644.     begin
  645.         with r do
  646.             begin
  647.                 X:=X1;
  648.                 Y:=Y1;
  649.                 W:=X2+1-X;
  650.                 H:=Y2+1-Y
  651.             end
  652.     end;
  653.  
  654.  
  655. function rc_intersect(r1: GRECT; var r2: GRECT): boolean;
  656.     var x,y,w,h: integer;
  657.     
  658.     begin
  659.         x:=Max(r2.X,r1.X);
  660.         y:=Max(r2.Y,r1.Y);
  661.         w:=Min(r2.X+r2.W,r1.X+r1.W);
  662.         h:=Min(r2.Y+r2.H,r1.Y+r1.H);
  663.         r2.X:=x;
  664.         r2.Y:=y;
  665.         r2.W:=w-x;
  666.         r2.H:=h-y;
  667.         if (w>x) and (h>y) then
  668.             begin
  669.                 GRtoA2(r2);
  670.                 rc_intersect:=true
  671.             end
  672.         else
  673.             rc_intersect:=false
  674.     end;
  675.  
  676.  
  677. procedure form_box(flag: integer; r: GRECT);
  678.  
  679.     begin
  680.         form_dial(flag,r.X+(r.W shr 1),r.Y+(r.H shr 1),1,1,r.X,r.Y,r.W,r.H)
  681.     end;
  682.  
  683.  
  684. function StrLPas(p: PChar; maxc: integer): string;
  685.     var s: string;
  686.  
  687.     begin
  688.         s:='';
  689.         if maxc>255 then maxc:=255;
  690.         if p<>nil then
  691.             while (p^<>#0) and (length(s)<maxc) do
  692.                 begin
  693.                     s:=s+p^;
  694.                     inc(longint(p))
  695.                 end;
  696.         StrLPas:=s
  697.     end;
  698.  
  699.  
  700. function VtoS(w: word): string;
  701.     var h,s: string[4];
  702.  
  703.     begin
  704.         h:='';
  705.         while w>0 do
  706.             begin
  707.                 h:=HexArray[byte(w and $000f)]+h;
  708.                 w:=w shr 4
  709.             end;
  710.         while length(h)<4 do h:='0'+h;
  711.         s:=h[1];
  712.         if s='0' then s:='';
  713.         VtoS:=s+h[2]+'.'+h[3]+h[4]
  714.     end;
  715.  
  716.  
  717. function DtoS(l: longint): string;
  718.     var h: string[8];
  719.         v: longint;
  720.         s: char;
  721.  
  722.     begin
  723.         h:='';
  724.         while l<>0 do
  725.             begin
  726.                 h:=HexArray[byte(l and $000f)]+h;
  727.                 l:=l shr 4
  728.             end;
  729.         while length(h)<8 do h:='0'+h;
  730.         if GetCookie('_IDT',v) then
  731.             begin
  732.                 s:=chr(v and $00ff);
  733.                 if s=#0 then s:='/';
  734.                 v:=(v and $0f00) shr 8
  735.             end
  736.         else
  737.             begin
  738.                 v:=1;
  739.                 s:='.'
  740.             end;
  741.         case v of
  742.             0: DtoS:=h[1]+h[2]+s+h[3]+h[4]+s+h[5]+h[6]+h[7]+h[8];
  743.             1: DtoS:=h[3]+h[4]+s+h[1]+h[2]+s+h[5]+h[6]+h[7]+h[8];
  744.             2: DtoS:=h[5]+h[6]+h[7]+h[8]+s+h[1]+h[2]+s+h[3]+h[4];
  745.             3: DtoS:=h[5]+h[6]+h[7]+h[8]+s+h[3]+h[4]+s+h[1]+h[2]
  746.         end
  747.     end;
  748.  
  749.  
  750. procedure GetDesk(var r: GRECT);
  751.  
  752.     begin
  753.         wind_get(DESK,WF_WORKXYWH,r.X,r.Y,r.W,r.H);
  754.         GRtoA2(r)
  755.     end;
  756.  
  757.  
  758. function Exist(FileName: string): boolean;
  759.     var olddta: DTAPtr;
  760.         newdta: DTA;
  761.  
  762.     begin
  763.         if not(AppFlag) then wind_update(BEG_UPDATE);
  764.         olddta:=FGetdta;
  765.         Fsetdta(@newdta);
  766.         Exist:=(Fsfirst(FileName,FA_RDONLY or FA_HIDDEN or FA_SYSTEM)=0);
  767.         Fsetdta(olddta);
  768.         if not(AppFlag) then wind_update(END_UPDATE)
  769.     end;
  770.  
  771.  
  772. function GetTempFilename: string;
  773.     var d,t  : word;
  774.         fname: string[8];
  775.  
  776.     begin
  777.         d:=tgetdate;
  778.         t:=tgettime;
  779.         fname:=HexArray[(d shr 12) and $0f]+HexArray[(d shr 8) and $0f]+HexArray[(d shr 4) and $0f]+HexArray[d and $0f];
  780.         fname:=fname+HexArray[(t shr 12) and $0f]+HexArray[(t shr 8) and $0f]+HexArray[(t shr 4) and $0f]+HexArray[t and $0f];
  781.         GetTempFilename:=StrPUpper(fname)+'.$$$'
  782.     end;
  783.  
  784.  
  785. function GetPath(FileName: string): string;
  786.  
  787.     begin
  788.         if pos('\',FileName)=0 then GetPath:=''
  789.         else
  790.             GetPath:=StrPLeft(FileName,RPos('\',FileName))
  791.     end;
  792.  
  793.  
  794. function GetDrives: longint;
  795.  
  796.     begin
  797.         GetDrives:=dsetdrv(dgetdrv)
  798.     end;
  799.  
  800.  
  801. procedure appl_yield;
  802.  
  803.     begin
  804.         evnt_timer(1,0)
  805.     end;
  806.  
  807.  
  808. begin
  809.     kt:=nil
  810. end.